// 1.算法题：https://leetcode-cn.com/problems/swap-nodes-in-pairs/

/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var swapPairs = function (head) {
  if (head && head.next) {
    const n = head.next;

    head.next = swapPairs(n.next);
    n.next = head;
    return n;
  } else {
    return head;
  }
};
// 2.手写题：https://bigfrontend.dev/zh/problem/implement-your-own-Object-create

/**
 * @param {any} proto
 * @return {object}
 */
 function myObjectCreate(proto) {
  // your code here
  if (Object.prototype.toString.call(proto) !== '[object Object]' && Object.prototype.toString.call(proto) !== '[object Function]') {
    throw 'error'
  }
  function F() { }
  F.prototype = proto
  return new F()
}